cmake_minimum_required(VERSION 3.0)

project(test_coverage)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")


find_package(Threads)
add_executable(test_coverage main.cpp sum.cpp)
target_link_libraries(test_coverage PRIVATE gtest gmock Threads::Threads)

if(CODE_COVERAGE)
    include(code-coverage)
    add_code_coverage_all_targets(
        EXCLUDE /usr/include/c++/* /usr/include/i386-linux-gnu/c++/*
    )
    target_code_coverage(${PROJECT_NAME} ALL)

    add_test(NAME RunAllTests 
    COMMAND $<TARGET_FILE:${PROJECT_NAME}> -s)
endif()